/**
 * @author 
 * @func 搜索历史记录功能
 * @param localStorage内部数据
 * @return localStorage内部数据
 */

export const addSearchHistory = (value) => {
        const date = new Date();
        const search_history = {
        value: value, isHistory: 1, timestamp: date.getTime()
    }
        const oldData = window.localStorage.getItem('search_history') ? window.localStorage.getItem('search_history') : '[]';
        const newData = JSON.parse(oldData)
        const res = newData.filter(item => item.value !== search_history.value)
        window.localStorage.setItem("search_history",
        JSON.stringify([search_history, ...res])
    );
}
    export const getSearchHistory = () => {
     return JSON.parse(window.localStorage.getItem('search_history'))
    }
    export const removeSearchHistory = () => {
     window.localStorage.removeItem("search_history")
    }